﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;

namespace PNut_Project_Lin
{
    public partial class Insurance : PhoneApplicationPage
    {

        List<checkCar> listInsurance = new List<checkCar>();

        public Insurance()
        {
            InitializeComponent();

            this.Loaded += new RoutedEventHandler(Insurance_Loaded);
        }

        void Insurance_Loaded(object sender, RoutedEventArgs e)
        {
            //throw new NotImplementedException();
            stbt.Visibility = System.Windows.Visibility.Collapsed;

            listInsurance.Add(new checkCar("วิริยะประกันภัย", "1557", "", "http://www.viriyah.co.th/customer/customer_branch.asp"));
            listInsurance.Add(new checkCar("กรุงเทพประกันภัย", "1620", "", "http://www.bangkokinsurance.com/home/garage.asp?key=62&region_code=MD"));
            listInsurance.Add(new checkCar("เอเซียประกันภัย", "022549977", "", "http://58.137.173.12/web/service/bangkok.php"));
            listInsurance.Add(new checkCar("MSIG", "027888000", "", "http://www.msig-thai.com/msig/html/article.aspx?contentid=77"));
            listInsurance.Add(new checkCar("เจ้าพระยาประกันภัย", "026486666", "", "http://www.allianzcp.com/claims_map_3.jsp"));


            InsuranceListBox.DataContext = listInsurance;

        }

        private void web_bt_Click(object sender, RoutedEventArgs e)
        {
            WebBrowserTask task = new WebBrowserTask();
            task.URL = listInsurance.ElementAt(InsuranceListBox.SelectedIndex).Link;
            task.Show();
        }

        private void tel_bt_Click(object sender, RoutedEventArgs e)
        {
            PhoneCallTask task = new PhoneCallTask();
            task.PhoneNumber = listInsurance.ElementAt(InsuranceListBox.SelectedIndex).Detail;
            task.DisplayName = listInsurance.ElementAt(InsuranceListBox.SelectedIndex).Name;
            task.Show();
        }

        private void InsuranceListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (InsuranceListBox.SelectedIndex != -1)
            {
                stbt.Visibility = System.Windows.Visibility.Visible;
            }
        }
    }
}